﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib"
                    xmlns:controls="clr-namespace:Controls;assembly=Controls">
    
    <Style TargetType="CheckBox">
        <Setter Property="BorderBrush" Value="{DynamicResource ColorBorderBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource LabelForegroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>
                            <Border x:Name="Border" Width="13" Height="13" CornerRadius="0" Background="White" BorderThickness="1" BorderBrush="Gray">
                                <Path Width="10" Height="10" x:Name="CheckMark" SnapsToDevicePixels="False" Stroke="{DynamicResource ColorThemeBrush}" StrokeThickness="2" Data="M 2 4 L 4 9 9 1" />
                            </Border>
                        </BulletDecorator.Bullet>
                        <ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" RecognizesAccessKey="True"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="false">
                            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="CheckMark" Property="Data" Value="M 0 7 L 7 0" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="LightGray" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="LightGray" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="LightGray" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Border" Property="Background" Value="#FF888888" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="#FF888888" />
                            <Setter Property="Foreground" Value="#FF888888"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CheckBoxTransparent" TargetType="CheckBox">
        <Setter Property="BorderBrush" Value="Transparent" />
    </Style>

    <Style x:Key="InvertCheckBox" TargetType="CheckBox">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="CheckBox">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}" VerticalAlignment="Center" />
                        <CheckBox IsChecked="{Binding Path=IsChecked, RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType=CheckBox}}" Margin="5,0,0,0" VerticalAlignment="Center" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
